﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace gChartSharp
{
    /// <summary>
    /// Extension methods
    /// </summary>
    public static class ChartExtensions
    {
        /// <summary>
        /// Converts a System.Drawing.Color object to its HTML hex equivalent
        /// </summary>
        /// <remarks>
        /// For example: Color.Red => "ff0000"
        /// </remarks>
        /// <param name="color"></param>
        /// <returns></returns>
        public static string ToHtml(this Color color)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("{0:x2}", color.R);
            sb.AppendFormat("{0:x2}", color.G);
            sb.AppendFormat("{0:x2}", color.B);
            return sb.ToString();
        }
    }
}
